package com.example.sys.pay.config;

import com.lly835.bestpay.config.AliPayConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SysAliPayConfig {

    /**
     * appId
     */
    @Value("${ali.pay.appId}")
    private String appId;
    /**
     * 商户私钥
     */
    @Value("${ali.pay.privateKey}")
    private String privateKey;
    /**
     * 支付宝公钥
     */
    @Value("${ali.pay.aliPayPublicKey}")
    private String aliPayPublicKey;
    /**
     * 异步通知url
     */
    @Value("${ali.pay.notifyUrl}")
    private String notifyUrl;

    /**
     * 同步返回的url
     */
    @Value("${ali.pay.returnUrl}")
    private String returnUrl;

    /**
     * 是否使用沙箱
     */
    @Value("${ali.pay.sandbox}")
    private Boolean sandbox;


    @Bean
    public AliPayConfig aliPayConfig() {
        AliPayConfig aliPayConfig = new AliPayConfig();
        aliPayConfig.setNotifyUrl(notifyUrl);
        aliPayConfig.setAppId(appId);
        aliPayConfig.setPrivateKey(privateKey);
        aliPayConfig.setAliPayPublicKey(aliPayPublicKey);
        aliPayConfig.setSandbox(sandbox);
        aliPayConfig.setReturnUrl(returnUrl);
        return aliPayConfig;
    }
}
